﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace VNAManagebank
{
    public class csdl
    {
        public static string strCon = @"Data Source=MRK-PC\MRKPC;Initial Catalog=VnaManageBank;User ID=sa;Password=123456";

        public csdl() { }

        public static int themsuaxoa(string sql)
        {
            System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection(strCon);
            con.Open();
            try
            {
                return new System.Data.SqlClient.SqlCommand(sql, con).ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                return -1;
            }
            finally
            {
                con.Dispose();
                con.Close();
            }
        }

        public static System.Data.DataTable hienthi(string sql)
        {
            //Dữ liệu (các bảng)
            System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection(strCon);
            con.Open();
            //Cầu nối
            System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter(sql, con);
            //Hộp chứa
            System.Data.DataSet ds = new System.Data.DataSet();
            //dùng cầu nối hút dữ liệu vào hộp chứa
            da.Fill(ds);
            con.Close();
            con.Dispose();
            return ds.Tables[0];
        }
    }
}
